/// 创建人： Created by zhaoin
/// 创建时间：Created by  on 2020/7/23.
///
/// 创建人： Created by zhaoin
/// 创建时间：Created by  on 2020/9/25.
///
/// gongzhonghao biglead
/// https://study.163.com/instructor/1021406098.htm
/// https://blog.csdn.net/zl18603543572
/// https://www.toutiao.com/c/user/token/MS4wLjABAAAAYMrKikomuQJ4d-cPaeBqtAK2cQY697Pv9xIyyDhtwIM/

///lib/app/bean/bean_catalog.dart
class ProblemModel {
  int id;
  String title;
  String options;

  int ruleTaskId;

  String answer;
  String categoryOne;
  String categoryTwo;

  int mineId;
  int textSize;
  String rightAnswer;
  String collection;

  String myAnswerStr;

  ///临时答案
  String themAnswerStr;

  QuestionType questionType;

  ///我的答案
  String myAnswer;

  ///回答信息提示
  String showAnswerMessage;

  ProblemModel.fromJson(Map<String, dynamic> map) {
    this.id = map["id"];
    this.title = map["title"];
    this.options = map["options"];
    this.answer = map["answer"];

    this.ruleTaskId = map["ruleTaskId"];

    this.categoryOne = map["categoryOne"];
    this.categoryTwo = map["categoryTwo"];
    this.mineId = map["mineId"];
    this.textSize = map["textSize"];

    this.rightAnswer = map["rightAnswer"];
    this.collection = map["collection"];
    this.myAnswerStr = map["myAnswerStr"];
    this.themAnswerStr = map["themAnswerStr"];

    String type = map["questionType"];

    if (type == null || type.length == 0) {
      this.questionType = QuestionType.NONE;
    } else if (type == "SINGLE_CHOICE") {
      this.questionType = QuestionType.SINGLE_CHOICE;
    } else if (type == "MULTIPLE_CHOICE") {
      this.questionType = QuestionType.MULTIPLE_CHOICE;
    } else if (type == "IUDGE") {
      this.questionType = QuestionType.IUDGE;
    } else if (type == "GAPFILL_CHOICE") {
      this.questionType = QuestionType.GAPFILL_CHOICE;
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> map = new Map<String, dynamic>();
    map["id"] = this.id;
    map["title"] = this.title;
    map["options"] = this.options;
    map["answer"] = this.answer;
    map["ruleTaskId"] = this.ruleTaskId;

    map["categoryOne"] = this.categoryOne;
    map["categoryTwo"] = this.categoryTwo;
    map["mineId"] = this.mineId;
    map["textSize"] = this.textSize;
    map["rightAnswer"] = this.rightAnswer;

    map["myAnswer"] = this.myAnswer;

    map["collection"] = this.collection;
    map["myAnswerStr"] = this.myAnswerStr;
    switch (this.questionType) {
      case QuestionType.SINGLE_CHOICE:
        map["questionType"] = "SINGLE_CHOICE";
        break;
      case QuestionType.MULTIPLE_CHOICE:
        map["questionType"] = "MULTIPLE_CHOICE";
        break;
      case QuestionType.IUDGE:
        map["questionType"] = "IUDGE";
        break;
      case QuestionType.GAPFILL_CHOICE:
        map["questionType"] = "GAPFILL_CHOICE";
        break;
      case QuestionType.NONE:
        break;
    }

    return map;
  }
}

enum QuestionType {
  /// 单选题**/
  SINGLE_CHOICE,

  /// 多选题**/
  MULTIPLE_CHOICE,

  /// 判断题**/
  IUDGE,

  /// 填空题**/
  GAPFILL_CHOICE,
  NONE,
}
